﻿// -----------------------------------------------------------------------
// <copyright file="RemoveUserCommandHandler.cs">
// Copyright (c) 2013-2014 Andrey Veselov. All rights reserved.
// License:  Microsoft Public License (MS-PL)
// Contacts: http://andrey.moveax.com  andrey@moveax.com
// </copyright>
// -----------------------------------------------------------------------

namespace Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.DataAccess.CommandHandlers.Users
{
	using System.Diagnostics.Contracts;
	using Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.DataAccess.Database.Dto;
	using Moveax.DataAccess.Cqrs.Highway.EF.UnitTests.Model.Commands.Users;

	internal class RemoveUserCommandHandler : ICommandHandlerSync<RemoveUserCommand>
	{
		private readonly IRepository _repository;

		public RemoveUserCommandHandler(IRepository repository)
		{
			Contract.Requires(repository != null);

			this._repository = repository;
		}

		public void Execute(RemoveUserCommand command)
		{
			this._repository.Remove(new UserDto() { Id = command.UserId });
		}
	}
}
